

import { Action } from '@ngrx/store';

import { DataTable } from '../../models';

export enum DataTableActionTypes {
    DATA_TABLE_ADD = '[Data Table] Add Data Table',
    DATA_TABLE_REMOVE = '[Data Table] Remove Data Table',
    DATA_TABLE_SHOW = '[Data Table] Show Data Table',
    DATA_TABLE_HIDE = '[Data Table] Hide Data Table',
    DATA_TABLE_SELECTED = '[Data Table] Selected Data Table',
    DATA_TABLE_DOWN = '[Data Table] Down Data Table',
    DATA_TABLE_MOUSE_OVER = '[Data Table] Mouse Over Data Table',
    DATA_TABLE_MOUSE_OUT = '[Data Table] Mouse Out Data Table',
    DATA_TABLE_DATA = '[Data Table] Data Table Data',
    DATA_TABLE_LOADED = '[Data Table] Data Table Loaded',
    DATA_TABLE_LOADING = '[Data Table] Data Table Loading',
    DATA_TABLE_LOAD_ERROR = '[Data Table] Data Table Load Error',
    DATA_TABLE_RESET = '[Data Table] Data Table Reset',
}

export class DataTableAdd implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_ADD;
    constructor(public payload: DataTable) { }
} 

export class DataTableRemove implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_REMOVE;
    constructor(public payload: string) { }
}

export class DataTableShow implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_SHOW;
}

export class DataTableHide implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_HIDE;
}

export class DataTableSelected implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_SELECTED;
    constructor(public payload: number) {}
}

export class DataTableDown implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_DOWN;
}

export class DataTableMouseOver implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_MOUSE_OVER;
    constructor(public payload: { layer: string, id: string }) { }
}

export class DataTableMouseOut implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_MOUSE_OUT;
    constructor(public payload: { layer: string, id: string }) { }
}

export class DataTableData implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_DATA;
    constructor(public payload: { id: string, data: { [id: string]: any }[] }) {}
}

export class DataTableLoaded implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_LOADED;
    constructor(public payload: string) {}
}

export class DataTableLoading implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_LOADING;
    constructor(public payload: string) {}
}

export class DataTableLoadError implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_LOAD_ERROR;
    constructor(public payload: string) {}
}

export class DataTableReset implements Action {
    readonly type = DataTableActionTypes.DATA_TABLE_RESET;
}

export type DataTableAction 
    = DataTableAdd
    | DataTableRemove
    | DataTableShow
    | DataTableHide
    | DataTableSelected
    | DataTableDown
    | DataTableMouseOver
    | DataTableMouseOut
    | DataTableData
    | DataTableLoaded
    | DataTableLoading
    | DataTableLoadError
    | DataTableReset;
